using System.Collections.Generic;
using System.Linq;
using Moq;
using NUnit.Framework;
using Tycho.Parser.Peg;

namespace Tycho.Parser.Tests.Peg {
    [TestFixture]
    public class ParseContextSpecification {
        [Test]
        public void LastIndentShouldBeCopied () {
            Assert.AreEqual ("    ", new ParseContext () {LastIndent = "    "}.Clone ().LastIndent);
        }

        [Test]
        public void BracketDepthShouldBeCopied () {
            Assert.AreEqual (8, new ParseContext () {BracketDepth = 8}.Clone ().BracketDepth);
        }

        [Test]
        public void GrammarShouldBeCopied () {
            var grammar = new LazyDynamicGrammar ();
            Assert.AreSame (grammar, new ParseContext () { DynamicGrammar = grammar }.Clone ().DynamicGrammar);
        }

        [Test]
        public void GrammarTreeShouldBeCopied () {
            var tree = new GrammarTree (new Mock<IProduction> ().Object);
            Assert.AreSame (tree, new ParseContext () { GrammarTree = tree }.Clone ().GrammarTree);
        }
    }
}